package com.tjetc.controller;

import com.tjetc.common.JsonResult;
import com.tjetc.entity.RelativeInfo;
import com.tjetc.service.RelativeInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("relativeinfo")
public class RelativeInfoController {
    @Autowired
    private RelativeInfoService relativeInfoService;

    @RequestMapping("detail/{familyId}")
    public JsonResult detail(@PathVariable("familyId") Long id) {
        return relativeInfoService.findById(id);
    }
    @RequestMapping("page")
    public JsonResult page(@RequestParam(value = "name", required = false,defaultValue = "") String name,
                               @RequestParam(value = "pageNo",required = false,defaultValue = "1") Integer pageNo,
                               @RequestParam(value = "pageSize",required = false,defaultValue = "2") Integer pageSize) {
        return relativeInfoService.findNamePage(name,pageNo,pageSize);
    }
    @RequestMapping("delete/{familyId}")
    public JsonResult delete(@PathVariable("familyId") Long id) {
        return relativeInfoService.deleteById(id);
    }
    //接收参数格式是json
    @RequestMapping("save")
    public JsonResult save(@RequestBody RelativeInfo relativeInfo){
        return relativeInfoService.save(relativeInfo);
    }
}
